﻿using System;

namespace OdaOperation.Model
{
    public class TableItem
    {
        public int RowSpan { get; set; } = 1;


        public int ColSpan { get; set; } = 1;


        public bool IsBlock { get; set; }

        public string Value { get; set; }

        public int TopIndex { get; internal set; }

        public int LeftIndex { get; internal set; }

        public double FontSize { get; set; } = double.NaN;


        public TableAlignment Align { get; set; } = TableAlignment.CenterCenter;


        public double Padding { get; set; } = double.NaN;


        public TableItem()
        {
        }

        public TableItem(string value, TableAlignment align = TableAlignment.CenterCenter, bool isBlock = false, int rowSpan = 1, int colSpan = 1)
        {
            IsBlock = isBlock;
            Value = value ?? throw new ArgumentNullException("value");
            Align = align;
            RowSpan = rowSpan;
            ColSpan = colSpan;
        }

        public static implicit operator TableItem(string value)
        {
            return new TableItem(value);
        }

        public static implicit operator TableItem((string value, TableAlignment alignment) value)
        {
            return new TableItem(value.value, value.alignment);
        }

        public static implicit operator TableItem((string value, bool isBlock) value)
        {
            return new TableItem(value.value, TableAlignment.CenterCenter, value.isBlock);
        }
    }
}